﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SimpleDataImport.aspx.cs"
    Inherits="InformationSystem.WebSite.UtilityPage.SimpleDataImport" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .cbStates-list
        {
            width: 298px;
            font: 12px tahoma,arial,helvetica,sans-serif;
        }
        .cbStates-list2
        {
            width: 470px;
            font: 12px tahoma,arial,helvetica,sans-serif;
        }
        .cbStates-list th
        {
            font-weight: bold;
        }
        
        .cbStates-list td, .cbStates-list th
        {
            padding: 3px;
        }
    </style>
    <script type="text/javascript">
        function changeitem(index) {
            if (index == 0) {
                comcon.hide()
            }
            else {
                comcon.show();
            }
        }

        function complete() {
            var win = parent.Ext.getCmp('mywindow');
            if (win)
                win.hide();
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager ID="ResourceManager1" runat="server">
    </ext:ResourceManager>
    <ext:Panel ID="WizardPanel" runat="server" Title="数据导入向导" Padding="15" Height="315"
        Layout="card" ActiveIndex="0">
        <Items>
            <ext:FormPanel runat="server" ID="BasicForm" Header="false" PaddingSummary="10px 10px 0 10px"
                MonitorValid="true" LabelWidth="30">
                <Defaults>
                    <ext:Parameter Name="anchor" Value="95%" Mode="Value">
                    </ext:Parameter>
                    <ext:Parameter Name="allowBlank" Value="false" Mode="Raw" />
                </Defaults>
                <Items>
                    <ext:Label ID="Label3" runat="server">
                        <Content>
                            <p style="font-size: 20px;">
                                欢迎使用数据导入向导</p>
                            <p style="font-size: 13px; margin-top: 10px; margin-bottom: 10px">
                                1.请选择导入类型</p>
                        </Content>
                    </ext:Label>
                    <ext:ComboBox runat="server" SelectedIndex="0" Editable="false" ID="cmbtype">
                        <Items>
                            <ext:ListItem Text="学生信息导入" Value="0" />
                            <ext:ListItem Text="学生成绩导入" Value="1" />
                        </Items>
                        <Listeners>
                            <Select Handler="changeitem(index)" />
                        </Listeners>
                    </ext:ComboBox>
                    <ext:CompositeField runat="server" ID="comcon" Hidden="true">
                        <Items>
                            <ext:Label ID="Label4" runat="server">
                                <Content>
                                    <p style="font-size: 13px; margin-top: 5px; margin-bottom: 2px">
                                        1.1 请选择课程成绩对应的学期</p>
                                </Content>
                            </ext:Label>
                            <ext:ComboBox runat="server" SelectedIndex="0" Editable="false" ID="cmbterm">
                                <Items>
                                    <ext:ListItem Text="第1学期" Value="1" />
                                    <ext:ListItem Text="第2学期" Value="2" />
                                    <ext:ListItem Text="第3学期" Value="3" />
                                    <ext:ListItem Text="第4学期" Value="4" />
                                    <ext:ListItem Text="第5学期" Value="5" />
                                    <ext:ListItem Text="第6学期" Value="6" />
                                    <ext:ListItem Text="第7学期" Value="7" />
                                    <ext:ListItem Text="第8学期" Value="8" />
                                </Items>
                            </ext:ComboBox>
                        </Items>
                    </ext:CompositeField>
                    <ext:Label ID="Label1" runat="server">
                        <Content>
                            <p style="font-size: 13px; margin-top: 6px; margin-bottom: 10px">
                                2.请选择需要导入的Excel文件(目前仅支持*.xls)</p>
                        </Content>
                    </ext:Label>
                    <ext:FileUploadField runat="server" ID="fileUpLoad" Icon="Attach" ButtonText="浏览...">
                    </ext:FileUploadField>
                    <ext:CompositeField runat="server">
                        <Items>
                            <ext:HyperLink runat="server" Text="学生信息模板" Icon="DiskDownload" NavigateUrl="../Template/学生信息模板.xls"
                                Target="_blank">
                            </ext:HyperLink>
                            <ext:HyperLink ID="HyperLink1" runat="server" Text="学生成绩模板" Icon="DiskDownload" NavigateUrl="../Template/学生成绩模板.xls"
                                Target="_blank">
                            </ext:HyperLink>
                        </Items>
                    </ext:CompositeField>
                </Items>
                <Listeners>
                    <ClientValidation Handler="#{SaveButton}.setDisabled(!valid);" />
                </Listeners>
                <Buttons>
                    <ext:Button ID="SaveButton" runat="server" Text="上传">
                        <DirectEvents>
                            <Click OnEvent="UploadClick" Before="if (!#{BasicForm}.getForm().isValid()) { return false; } 
                                Ext.Msg.wait('正在上传文件，请稍后...', '上传');" Failure="Ext.Msg.show({ 
                                title   : '错误', 
                                msg     : '上传错误，请重试！', 
                                minWidth: 200, 
                                modal   : true, 
                                icon    : Ext.Msg.ERROR, 
                                buttons : Ext.Msg.OK 
                            });">
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                    <ext:Button runat="server" Text="清空">
                        <Listeners>
                            <Click Handler="#{BasicForm}.getForm().reset();" />
                        </Listeners>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
            <ext:FormPanel runat="server" ID="ImportPanel" Header="false" PaddingSummary="10px 10px 0 10px"
                MonitorValid="true" LabelWidth="30">
                <Items>
                    <ext:Label ID="Label2" runat="server">
                        <Content>
                            <p style="font-size: 20px;">
                                欢迎使用数据导入向导</p>
                        </Content>
                    </ext:Label>
                    <ext:ProgressBar ID="probar" runat="server" FieldLabel="进度" AutoHeight="true">
                    </ext:ProgressBar>
                    <ext:TextArea ID="txtlog" runat="server" AllowBlank="true" FieldLabel="日志" Height="140"
                        ReadOnly="true" AnchorHorizontal="100%">
                    </ext:TextArea>
                </Items>
                <Buttons>
                    <ext:Button runat="server" ID="btnImport" Text="导入">
                        <DirectEvents>
                            <Click OnEvent="btnImport_Click">
                            </Click>
                        </DirectEvents>
                    </ext:Button>
                    <ext:Button ID="btnFinish" runat="server" Text="完成" Hidden="true">
                        <Listeners>
                            <Click Handler="complete()" />
                        </Listeners>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
        </Items>
    </ext:Panel>
    <ext:TaskManager runat="server" ID="taskmgr">
        <Tasks>
            <ext:Task TaskID="importprogress" Interval="1000" AutoRun="false" OnStart="
                        #{btnImport}.setDisabled(true);" OnStop="
                        #{btnImport}.hide();#{btnFinish}.show();">
                <DirectEvents>
                    <Update OnEvent="RefreshProgress" />
                </DirectEvents>
            </ext:Task>
        </Tasks>
    </ext:TaskManager>
    </form>
</body>
</html>
